package com.lanou.musicproject.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

import com.lanou.musicproject.R;


/**
 * Created by 王世美 on 15/10/9.
 */
//启动页
public class AdActivity extends Activity {
    private final int SPLASH_DISPLAY_LENGHT = 3000;
    private SharedPreferences preferences;
    private SharedPreferences.Editor editor;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ad);
        preferences = getSharedPreferences("phone", Context.MODE_PRIVATE);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (preferences.getBoolean("firststart", true)) {//如果第一次启动跳转到AndyViewPagerActivity页面
                    editor = preferences.edit();
                    editor.putBoolean("firststart", false);
                    editor.commit();
                    Intent intent=new Intent();
                    intent.setClass(AdActivity.this,AndyViewPagerActivity.class);
                    AdActivity.this.startActivity(intent);
                    AdActivity.this.finish();
                } else {       //不是第一次启动跳转到MainActivity页面
                    Intent intent=new Intent();
                    intent.setClass(AdActivity.this,MainActivity.class);
                    AdActivity.this.startActivity(intent);
                    AdActivity.this.finish();
                }
            }
        },SPLASH_DISPLAY_LENGHT);

    }
    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onPause() {
        super.onPause();

    }
}
